<?php
namespace Home\Controller;

use Think\Controller;
use Home\Model\AdminModel;

class IndexController extends Controller
{
	public function index(){
		$this->display();
	}
	public function login(){

		$username = I('post.username');
		$password = sha1(I('post.password'));

		if(!empty($_POST)){
			
			$user = new AdminModel();
            $rst  = $user->checkNamePwd($username, $password);

            if ($rst != false ) {
                        
                session_start();
                $_SESSION['username'] = $username;
                
                $this->redirect('Admin/index', 0);

            } else{

            	$this->redirect('Index/index', 0);
            	$this->assign('reminder','用户名和密码不正确');
            }
		}
	}	
} 